package com.sitc.administrator.application.fragment;

import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.sitc.administrator.application.R;
import com.sitc.administrator.application.adapter.ConversationAdapter;
import com.sitc.administrator.application.domain.Conversation;
import com.sitc.administrator.application.util.StaticValue;

import java.util.ArrayList;
import java.util.List;

public class MainMsgFragment extends BaseCommonFragment {

    private Integer id;

    private RecyclerView rv;

    private ConversationAdapter adapter;

    public static MainMsgFragment newInstance(int id) {

        Bundle args = new Bundle();
        args.putSerializable(StaticValue.ID, id);
        MainMsgFragment fragment = new MainMsgFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initViews() {
        super.initViews();

        rv = findViewById(R.id.rv);
        rv.setHasFixedSize(true);

        final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        rv.setLayoutManager(layoutManager);

        DividerItemDecoration decoration = new DividerItemDecoration(getActivity(), RecyclerView.VERTICAL);
        rv.addItemDecoration(decoration);

        adapter = new ConversationAdapter(getActivity(),R.layout.item_conversation);


        List<Conversation> conversations = new ArrayList();
        conversations.add( new Conversation());
        conversations.add( new Conversation());
        conversations.add( new Conversation());
        //Conversation conversations = new Conversation();
        adapter.setData(conversations);

        rv.setAdapter(adapter);

    }

    @Override
    protected void initDatas() {
        super.initDatas();

    }

    @Override
    protected void initListener() {
        super.initListener();
    }


    @Override
    protected View getLayoutView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_main_msg,null);
    }

}
